package edu.hunau.cxb.controller;

import edu.hunau.cxb.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @author hb
 * @create 2020-03-31 11:07
 */
@Controller
public class JSONTestController {

    @RequestMapping("/testJsonUsers")
    public @ResponseBody List<User> testJsonUsers(){
        List<User> users=new ArrayList<User>();
        users.add(new User(1001,"haoren01","250", LocalDate.now()));
        users.add(new User(1002,"haoren02","250", LocalDate.now()));
        users.add(new User(1003,"haoren03","250", LocalDate.now()));
        users.add(new User(1004,"haoren04","250", LocalDate.now()));

        return users;
    }

    @RequestMapping(value="/reqJsonTest",method= RequestMethod.POST)
    public @ResponseBody String reqJsonTest( @RequestBody User user){

        System.out.println(user);
        return "成功";
    }
}
